classdef cPerfusion
    %CPERFUSION cPerfusion is a class to collect, show and save the perfusion results
    %   Members:
    %       dCBF    - cMRI obj to collect CBF results
    %       dDT     - cMRI obj to collect AAT results
    %       maskType- String to indicate which mask is used
    %       numRep  - String or vector to indicate how many repetitions are
    %                 used
    %       method  - String to indicate which method is used
    %       selTi   - String to indicate which Tis are used
    %   Functions:
    %       INITIALIZE()
    %         Initialize the objects with results of CBF and AAT, as well
    %         as indicating the mask type, number of repetitions, selected
    %         Tis and the method used for quantification. More details see
    %         its implements.
    %       SHOWRESULT()
    %         Show the results with standard MRI review window, in order to
    %         display the noisy measurments and the estimated curves, the
    %         original cDIVASL obj should be indicated.
    %       SAVERESULTS()
    %         Save the calculated results in a given path, the filenames
    %         are pre-fixed and can be modified in the implements.
    % COPYRIGHT RESERVED 2012 @ INRIA/IRISA VISAGES, LEI YU
    % See also: cMRI, cDIVASL
    
    properties
        dCBF = cMRI();
        dDT = cMRI();
                
        maskType = 'gray';
        numRep = 'all';
        
        method = 'cmf';
        selTi = 1:11;
        
    end
    
    methods
        function obj = initialize(obj,objCBF,objDT,maskType,numRep,selTi,method)
            obj.dCBF = obj.dCBF.initialMRI(objCBF);
            obj.dDT = obj.dDT.initialMRI(objDT);
            
            obj.maskType = maskType;
            if strcmp(numRep,':')
                numRep = 'all';
            end
            obj.numRep = numRep;
            obj.method = method;
            obj.selTi = selTi;
            
        end
        
        function showResult(obj,cbf_dt,obj_divasl,varargin)
            if isempty(cbf_dt)
                cbf_dt = 'cbf';
            end
            if strcmp(cbf_dt,'cbf')
                obj.dCBF.showMRI('Div-TI, CBF',obj_divasl,obj.method);
            else
                obj.dDT.showMRI('Div-TI, AAT',obj_divasl,obj.method);
            end
        end
        
        function saveResults(obj,filePath,fileLog,varargin)
            filename = ['Divasl_CBF_AAT_',obj(1).maskType,...
                        '_REPs',num2str(length(str2num(obj(1).numRep))),...
                        '_TIs',num2str(length(obj(1).selTi)),...
                        '_method_',obj(1).method];
            filename = [filename,fileLog,'.mat'];
            saveFile = fullfile(filePath,filename);
            save(saveFile,'obj');
        end
    end
    
end

